package edu.sctu.xialei.june.day20150628two_test.IO;

import java.io.File;
import java.io.IOException;

/**
 * Created by Administrator on 2015/6/28.
 */
public class FileUtil {

    private File file;

    //    create File method
    public void createFile(String path) {
        file = new File(path);

        if (!file.exists()) {
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            System.out.println("the File you typed is already existed");
        }
    }

    //    delete File or Folder method
    public void deleteFileOrFolder(String path) {
        file = new File(path);

        if (file.exists()) {
            file.delete();
        } else {
            System.out.println("the File or Folder path you typed is not existed");
        }
    }

    //    create Folder method
    public void createFolder(String path) {
        file = new File(path);

        if (!file.exists()) {
            file.mkdirs();
        } else {
            System.out.println("the Folder you typed is existing");
        }
    }
}
